package _2022.hot100._208_实现前缀树;

import java.util.HashSet;
import java.util.Set;

/**
 * @author： YHSimon
 * @date： 2022-05-14 16:12
 */
public class Trie {
    private Set<String> set;
    public Trie(){
        this.set=new HashSet<>();
    }

    public void insert(String word){
        set.add(word);
    }

    public boolean search(String word){
        return set.contains(word);
    }

    public boolean startsWith(String prefix){
        for (String s : set) {
            if(s.length()>=prefix.length()&&s.substring(0, prefix.length()).equals(prefix)){
                return true;
            }
        }
        return false;
    }


    public static void main(String[] args) {
        Trie trie = new Trie();

    }
}
